<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/views1/DTD/views1-transitional.dtd">
<f:view xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.prime.com.tr/ui">

	<p:dialog widgetVar="promptBuscaOfertaDisciplina" modal="true"
		width="500" closable="true" header="Buscar Oferta de Disciplina"
		minWidth="500" >
		<h:form id="formPromptBuscaOfertaDisciplina">
			<div>
				<div class="prompt-div-label width_3">Disciplina:</div>
				<div class="prompt-div-campo">
					<h:selectOneMenu value="#{ofertaDisciplinaBean.idDisciplina}"
						styleClass="ui-inputfield ui-widget ui-state-default ui-corner-all  width_6">
						<f:selectItem itemLabel="--- Selecione ---"
							noSelectionOption="true" itemValue="0" />
						<f:selectItems value="#{ofertaDisciplinaBean.disciplinaList}"
							var="disc" itemValue="#{disc.id}" itemLabel="#{disc.nome}" />
					</h:selectOneMenu>
				</div>
				<div class="prompt-div-label width_3">Professor:</div>
				<div class="prompt-div-campo">
					<h:selectOneMenu value="#{ofertaDisciplinaBean.idProfessor}"
						styleClass="ui-inputfield ui-widget ui-state-default ui-corner-all width_6">
						<f:selectItem itemLabel="--- Selecione ---"
							noSelectionOption="true" itemValue="0" />
						<f:selectItems value="#{ofertaDisciplinaBean.professorList}"
							var="prof" itemValue="#{prof.id}"
							itemLabel="#{prof.nomeCompleto}" />
					</h:selectOneMenu>
				</div>
				<div class="prompt-div-label width_3">Ano/Semestre:</div>
				<div class="prompt-div-campo">
					<h:selectOneMenu value="#{ofertaDisciplinaBean.buscaAno}"
						styleClass="ui-inputfield ui-widget ui-state-default ui-corner-all width_3">
						<f:selectItem itemLabel="----" itemValue="0"
							noSelectionOption="true" />
						<f:selectItems value="#{ofertaDisciplinaBean.anosList}" />
					</h:selectOneMenu>
					<p:spacer styleClass="width_1" height="1" />
					<h:selectOneMenu value="#{ofertaDisciplinaBean.buscaSemestre}"
						styleClass="ui-inputfield ui-widget ui-state-default ui-corner-all width_2">
						<f:selectItem itemLabel="--" itemValue="0"
							noSelectionOption="true" />
						<f:selectItem itemLabel="01" itemValue="1" />
						<f:selectItem itemLabel="02" itemValue="2" />
					</h:selectOneMenu>
					<p:spacer height="0" width="30"></p:spacer>
					<p:commandButton value="Filtrar" styleClass="prompt-btnFiltro"
						action="#{ofertaDisciplinaBean.filtrarOfertaDisciplina}"
						update="dataTableBuscaOfertaDisciplina" ajax="true" />
				</div>
				<div class="clear"></div>
			</div>
			<div>
				<p:dataTable widgetVar="dataTableBuscaOfertaDisciplina"
					id="dataTableBuscaOfertaDisciplina" paginator="true"
					selection="#{ofertaDisciplinaBean.ofertaInstanceTemp}"
					value="#{ofertaDisciplinaBean.ofertaList}" selectionMode="single"
					var="o" emptyMessage="Nenhum registro encontrado!" rows="10"
					dynamic="true">
					<p:column headerText="Discipina">
						<h:outputText value="#{o.disciplina.nome}" />
					</p:column>
					<p:column headerText="Professor">
						<h:outputText value="#{o.professor.nomeCompleto}" />
					</p:column>
					<p:column headerText="Semestre">
						<h:outputText value="#{o.semestre}" />
					</p:column>
					<p:column headerText="Ano">
						<h:outputText value="#{o.ano}">
							<f:convertDateTime pattern="yyyy"></f:convertDateTime>
						</h:outputText>
					</p:column>
				</p:dataTable>
			</div>
			<div style="text-align: right;">
				<br />
				<p:separator />
				<br />
				<p:commandButton
					action="#{ofertaDisciplinaBean.selecionarOfertaDisciplina}"
					value="Selecionar"
					update="formPrincipal, dataTableBuscaOfertaDisciplina"
					onclick="promptBuscaOfertaDisciplina.hide()" />
				<p:commandButton type="button" value="Cancelar"
					onclick="promptBuscaOfertaDisciplina.hide()" />
			</div>
		</h:form>
	</p:dialog>
</f:view>